# 1.打开浏览器
from time import sleep

from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By

service = Service(executable_path=r'E:\python\pythonshuju\chromedriver.exe')
driver = webdriver.Chrome(service=service)  #创建浏览器对象
# 2.输入访问地址（URL）
driver.get("http://121.43.169.97:8848/pageA.html")
# 3.页面信息操作
#实例化并获取ActionChains类
action = ActionChains(driver)

# #定位用户名 在用户名上 右击鼠标
# username = driver.find_element(By.CSS_SELECTOR, '#userA')
# #调用右击方法
# cc = action.context_click(username)
# #执行
# cc.perform()
# cc = action.context_click(username)


#输入用户名admin
username2 = driver.find_element(By.CSS_SELECTOR, '#userA').send_keys("admin")
sleep(3)

#双击鼠标左键，选中admin
dc = action.double_click(username2)
dc.perform()

#鼠标移动到‘注册按钮’，预期：按钮变色
button = driver.find_element(By.XPATH,"//p[5]/button")
action.move_to_element(button).perform()
# 4.关闭/退出浏览器
driver.quit()